import { request } from "./index"
/** 获取商品评价列表
 * 
 * @param {string} goodsId
 * @param {string} grade
 * @param {number} page 
 * @param {string} token
 */

const getComment = (goodsId, grade, page, token) => {
  return request.get(`v2/app/member/evaluation/${goodsId}/goodsEvaluation`, {
    page,
    grade
  },{
    'Authorization': token
  })
}
/** 获取商品评价数量
 * 
 * @param {string} goodsId
 * @param {string} token
 */
const getCommentNum = (goodsId, token) => {
  return request.get(`v2/app/member/evaluation/${goodsId}/evaluationNumber`, {}, {
    'Authorization': token
  })
}
/** 查看评价详情
 * 
 * @param {string} id
 */
const getCommentDetail = (id, token) => {
  return request.get(`v1/member/evaluation/get/${id}`, {}, {
    'Authorization': token
  })
}
/** 添加评价
 * 
 * @param {object} data
 * @param {string} data.content
 * @param {string} data.deliveryScore
 * @param {string} data.descriptionScore
 * @param {string} data.goodsId
 * @param {string} data.grade
 * @param {string} data.images
 * @param {string} data.serviceScore
 * @param {string} data.skuId
 * @param {string} token
 */
const addComment = (data, token) => {
  return request.post(`v1/app/member/evaluation`, data, {
    'Authorization': token,
    'content-type': 'application/x-www-form-urlencoded'
  })
}
/** 我的评价列表
 * 
 * @param {object} data
 * @param {string} data.endTime
 * @param {string} data.goodsId
 * @param {string} data.goodsName
 * @param {string} data.grade
 * @param {string} data.haveImage
 * @param {number} data.page
 */
const myCommentList = (data, token) => {
  return request.get(`v1/app/member/evaluation`, data, {
    'Authorization': token
  })
}
export {
  getComment,
  getCommentNum,
  getCommentDetail,
  addComment,
  myCommentList
}